<template>
	<div class="wrapper">
		<div class="pay-wrapper text-white">
			<h2>签约合同成功!</h2>
		</div>
		<view class=" mx-3 my-4 p-2 rounded-circle text-center fs-32 font-weight-bold">{{seconds}}s</view>
		<view class="bg-white mx-3 my-4 p-2 rounded-circle text-center"
			@tap="navigateTo(`/pages/order/orderDetail?sn=${sn}`)">返回</view>
	</div>

</template>
<script>
	export default {
		data() {
			return {
				sn: '',
				seconds: 5
			};
		},
		onLoad(options) {
			this.sn = options.sn
			this.countDown5s()
		},
		onUnload() {
			clearInterval(this.timer); // 结束倒计时
			this.timer = null
		},
		methods: {
			viewContract() {
				this.navigateTo(`/pages/navigation/webview?type=READ_FILE&sn=${this.sn}`);
			},

			navigateTo(url, type) {
				clearInterval(this.timer); // 结束倒计时
				this.timer = null
				if (type === "switch") {
					uni.switchTab({
						url,
					});
				} else {
					uni.redirectTo({
						url,
					});
				}
			},
			countDown5s() {
				clearInterval(this.timer); // 结束倒计时
				this.timer = null
				this.timer = setInterval(() => {
					this.seconds--;
					if (this.seconds <= 0) {
						clearInterval(this.timer); // 结束倒计时
						this.navigateTo(`/pages/order/orderDetail?sn=${this.sn}`)
					}
				}, 1000); // 1秒执行一次
			}
		},
	};
</script>
<style scoped lang="scss">
	.subscribe {
		justify-content: space-between;
		align-items: center;
		margin: 0 auto 40rpx auto;
		padding: 0 20rpx 20rpx;
		width: 80%;
	}

	.pay-btns {
		display: flex;
		width: 50%;
		justify-content: space-between;
		margin: 0 auto;
		color: #fff;

		>div {
			padding: 6px 12px;
			border: 1px solid #fff;
			border-radius: 100px;
		}
	}

	.pay-money {
		line-height: 1;
		font-size: 50rpx;
		color: #fff;
		margin-bottom: 50rpx;
	}

	.pay-item {
		font-weight: bold;
		margin: 32rpx 0;
		display: flex;
		justify-content: space-between;
		font-size: 24rpx;
		color: rgba($color: $main-color, $alpha: 0.8);
	}

	.pay-box {
		overflow: hidden;
	}

	.pay-tag-box {
		width: 80%;
		margin: 80rpx auto 40rpx auto;
		padding: 20rpx;
		border-radius: 20rpx;
		background: rgba($color: $main-color, $alpha: 0.2);

		>h2 {
			margin-top: 20rpx;
			font-size: 40rpx;
			color: $main-color;
		}
	}

	.pay-wrapper {
		background-image: linear-gradient(90deg, #fa123b, #ff6b35, #ff9f28, #ffcc03);
		height: 380rpx;
		position: relative;
		display: flex;
		align-items: center;
		justify-content: center;
		flex-direction: column;
	}

	.pay-box {
		transform: translateY(-20rpx);
		width: 100%;
		background: #fff;
		border-top-left-radius: 30rpx;
		border-top-right-radius: 30rpx;
	}
</style>